package com.group6.exam.teacher.service;

import java.util.List;
import java.util.Map;

import com.group6.exam.common.entity.PageModel;
import com.group6.exam.teacher.dao.ISubjectDao;
import com.group6.exam.teacher.dao.SubjectDaoImpl;
import com.group6.exam.teacher.entity.SubjectEntity;

public class SubjectServiceImpl implements ISubjectService {
	ISubjectDao subjectDao = new SubjectDaoImpl();

	@Override
	public int addSubject(SubjectEntity subject) {
		return subjectDao.addSubject(subject);
	}

	@Override
	public List<Map<String, Object>> getSubjectInfo() {
		// TODO Auto-generated method stub
		return subjectDao.getSubjectInfo();
	}

	@Override
	public int deleteSubjectbyId(String subjectId) {
		// TODO Auto-generated method stub
		return subjectDao.deleteSubjectbyId(subjectId);
	}

	@Override
	public List<Map<String, Object>> getsubjectInfoById(String subjectId) {
		return subjectDao.getsubjectInfoById(subjectId);
	}

	@Override
	public int updateSubjectById(SubjectEntity subjectEntity) {
		return subjectDao.updateSubjectById(subjectEntity);
	}

	@Override
	public PageModel check(PageModel pageModel) {
		// 查询总条数
		int totalRecords = subjectDao.getTotalRecords();
		int pageSize = pageModel.getPageSize();
		// 获取总页数
		PageModel page = new PageModel(totalRecords, pageSize);
		// 设置当前页
		page.setCurrentPage(pageModel.getCurrentPage());
		// 设置每页显示数据的集合对象
		page.setList(subjectDao.getPaging(pageModel));

		return page;
	}

}
